home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 1.5 KB | 45 lines | [TEXT/MACA] |
- Here's a snippet. It returns the vRefNum and DirID of the System Folder. It does it the right way under both 6.0 and 7.0.
- ---------------
-
- #define BTstQ(arg, bitnbr) (arg & (1 << bitnbr))
-
- /* FindSysFolder returns the (real) vRefNum, and the DirID of the current
- system folder. It uses the Folder Manager if present, otherwise it falls
- back to SysEnvirons. It returns zero on success, otherwise a standard
- system error. */
-
- OSErr FindSysFolder(short *foundVRefNum, long *foundDirID)
- {
- long gesResponse;
- SysEnvRec envRec;
- WDPBRec myWDPB;
- unsigned char volName[34];
- OSErr err;
-
-
- *foundVRefNum = 0;
- *foundDirID = 0;
- if (!Gestalt (gestaltFindFolderAttr, &gesResponse) &&
- BTstQ (gesResponse, gestaltFindFolderPresent)) { /* Does Folder Manager
- exist? */
- err = FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder,
- foundVRefNum, foundDirID);
- } else {
- /* Gestalt can't give us the answer, so we resort to SysEnvirons */
- if (!(err = SysEnvirons (curSysEnvVers, &envRec))) {
- myWDPB.ioVRefNum = envRec.sysVRefNum;
- volName[0] = '\000'; /* Zero volume name */
- myWDPB.ioNamePtr = volName;
- myWDPB.ioWDIndex = 0;
- myWDPB.ioWDProcID = 0;
- if (!(err = PBGetWDInfo (&myWDPB, 0))) {
- *foundVRefNum = myWDPB.ioWDVRefNum;
- *foundDirID = myWDPB.ioWDDirID;
- }
- }
- }
- return (err);
- }
- ======================================================================
-
-